package ils.web.action;

import ils.domain.issue.model.Issue;
import ils.web.model.MyIssue;
import ils.services.IssueService;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import ils.web.util.WebUtil;

public class ListIssuesAction extends ActionSupport
{
    private List<MyIssue> issueDetails;
    private IssueService issueService;
    private int firstResult;
    public String execute() throws Exception
    {
        List<Issue> issues = issueService.getOpenIssues(firstResult);
        issueDetails = WebUtil.convertToIssueDetails(issues);
        if(issueDetails.size() < IssueService.ISSUES_PAGE_SIZE) firstResult = -1;
        else firstResult = firstResult + IssueService.ISSUES_PAGE_SIZE;
        return SUCCESS;
    }

    public List<MyIssue> getIssueDetails()
    {
        return issueDetails;
    }

    public void setIssueDetails(List<MyIssue> issueDetails)
    {
        this.issueDetails = issueDetails;
    }

    public void setIssueService(IssueService issueService)
    {
        this.issueService = issueService;
    }

    public int getFirstResult()
    {
        return firstResult;
    }

    public void setFirstResult(int firstResult)
    {
        this.firstResult = firstResult;
    }
    
}
